﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMathLibrary.NonlinearEquationSolvers
{
    /// <summary>
    /// This class is an abstract internal base for the iterative root finding algorithm.
    /// </summary>
    [Serializable]
    public abstract class AbstractRootFinder
    {
        /// <summary>
        /// Describes if the calculated roots have a precision error.
        /// </summary>
        private bool precisionError;

        /// <summary>
        /// The relative error of the result.
        /// </summary>
        private double relativeError;

        /// <summary>
        /// The needed iterations for the root finding.
        /// </summary>
        private int neededIterations;

        /// <summary>
        /// Initializes a new instance of the <see cref="AbstractRootFinder"/> class.
        /// </summary>
        protected AbstractRootFinder()
        {
        }

        /// <summary>
        /// Describes if the calculated roots have a precision error. If true the
        /// calculated roots may be not correct.
        /// </summary>
        /// <value><c>True</c> if [precision error]; otherwise, <c>false</c>.</value>
        public bool PrecisionError
        {
            get { return precisionError; }
            set { precisionError = value; }
        }

        /// <summary>
        /// Gets the relative error of the result.
        /// </summary>
        /// <value>The relative error of the result.</value>
        public double RelativeError
        {
            get { return relativeError; }
            set { relativeError = value; }
        }

        /// <summary>
        /// Gets the needed iterations for the root finding.
        /// </summary>
        /// <value>The needed iterations for the root finding.</value>
        public int NeededIterations
        {
            get { return neededIterations; }
            set { neededIterations = value; }
        }
    }
}